package pantallas;
import bdelegate.BDelegate;

import com.cloudgarden.layout.AnchorConstraint;
import com.cloudgarden.layout.AnchorLayout;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.rmi.RemoteException;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class IngresoUsuario extends javax.swing.JFrame {
	private JTextField jtUsuaio;
	private JButton jbValidar;
	private JButton jbCancelar;
	private JLabel jlLegajo;
	private BDelegate bDel;

	/**
	* Auto-generated main method to display this JFrame
	*/
		
	public IngresoUsuario(BDelegate bd) {
		super("Validar Usuario");
		bDel = bd;
		initGUI();
	}
	
	private void initGUI() {
		try {
			AnchorLayout thisLayout = new AnchorLayout();
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				jbCancelar = new JButton();
				getContentPane().add(jbCancelar, new AnchorConstraint(570, 410, 775, 152, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
				jbCancelar.setText("Cancelar");
				jbCancelar.setPreferredSize(new java.awt.Dimension(99, 38));
				jbCancelar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						show(false);
						//System.out.println("jbCancelar.actionPerformed, event="+evt);
						//TODO add your code for jbCancelar.actionPerformed
					}
				});
			}
			{
				jbValidar = new JButton();
				getContentPane().add(jbValidar, new AnchorConstraint(570, 837, 775, 592, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
				jbValidar.setText("Validar");
				jbValidar.setPreferredSize(new java.awt.Dimension(94, 38));
				jbValidar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						String Salida = null;
						try {
							Salida = bDel.obtenerIdUsuario(Integer.parseInt(jtUsuaio.getText()));
						} catch (NumberFormatException | RemoteException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
							Salida = "Usuario no encontrado";
						}
						//jtSalida.setText(Salida);
						System.out.println("jbValidar.actionPerformed, event="+evt);
						//TODO add your code for jbValidar.actionPerformed
					}
				});
			}
			{
				jlLegajo = new JLabel();
				getContentPane().add(jlLegajo, new AnchorConstraint(170, 381, 272, 191, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
				jlLegajo.setText("Legajo");
				jlLegajo.setPreferredSize(new java.awt.Dimension(73, 19));
			}
			{
				jtUsuaio = new JTextField();
				getContentPane().add(jtUsuaio, new AnchorConstraint(159, 795, 305, 428, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
				jtUsuaio.setPreferredSize(new java.awt.Dimension(141, 27));
			}
			pack();
			this.setSize(400, 224);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
